package com.lwlk.util.reflact;

import com.lwlk.util.string.Lines;

import java.util.function.Function;

public class Make {

    public static <T> Wapper<T> it(T o) {
        return new Wapper<T>(o);
    }

    private static class Wapper<T> {

        private enum NameConfig { SIMAPLE , CANONICAL, FULL }

        private T object;

        private NameConfig nameconfig;

        private Wapper(T object) {
            this.object = object;
            this.nameconfig = NameConfig.SIMAPLE;
        }

        public Wapper<T> setSimaple() { nameconfig = NameConfig.SIMAPLE; return this; }

        public Wapper<T> setCanonical() { nameconfig = NameConfig.CANONICAL; return this; }

        public Wapper<T> setFull() { nameconfig = NameConfig.FULL; return this; }

        public String readable() {

            Class<?> clazz = object.getClass();

            return new Lines(
                    clazz.getCanonicalName(),
                    clazz.getName(),
                    clazz.getSimpleName(),
                    clazz.getTypeName()).with(" ,").content();
        }

        private <V extends Class<T>> Function<V, String> itsName() {

            switch(nameconfig) {
                case SIMAPLE:   return Class::getSimpleName;
                case CANONICAL: return Class::getCanonicalName;
                case FULL:      return Class::getTypeName;
                default:        return Class::getSimpleName;
            }
        }
    }

    public static void main(String[] args) {

        System.out.println(Make.it("").readable());
    }




    // Make.it([1 2 3]).readable() => "[1 2 3]"

    // make.it("a", 123, "b", new StringBuffer("asdf")).instanceOf(Pair.class) => Pair[a = 123, b = StringBuffer[asdf]]
}
